// Bachelor of Software Engineering 
// Media Design School 
// Auckland
// New Zealand
// 
// (c) 2005 - 2014 Media Design School 
// 
// File Name : Win32GameEngine.cpp
// Description : Win32GameEngine implementation
// Author : Serge Radinovich
// Mail : srad015@hotmail.com

#include "Win32GameEngine.h"

////////////////////////////
//Constructor
///////////////////////////
Win32GameEngine::Win32GameEngine(void)
{
}

////////////////////////////
//Destructor
///////////////////////////
Win32GameEngine::~Win32GameEngine(void)
{
}


////////////////////////////
//Initialize every bitmap in the game
///////////////////////////
HDC Win32GameEngine::InitializeBitmap(int _iResourceID)
{
	HBITMAP hBitmap = LoadBitmap(m_hInstance, MAKEINTRESOURCE(_iResourceID));
	HDC image_DC = CreateCompatibleDC(m_hDC);
	HBITMAP old_hbitmap = (HBITMAP)SelectObject(image_DC, hBitmap);
	return image_DC;
}


////////////////////////////
//Not used in Solitaire :)
///////////////////////////
void Win32GameEngine::ShowFPS()
{
	static double _iFrameCount = 0;
	static double _dTimeElapsed = 0.0;
	static TCHAR _buffer[256];

	++_iFrameCount;

	_dTimeElapsed += m_pTime->dDeltaTime;

	double percentOfSecond = 1 / m_pTime->dDeltaTime;

	_iFrameCount = percentOfSecond;

	wsprintf(_buffer, L"FPS: %d", (int)_iFrameCount);
	
	SelectObject(m_pBackBuffer->getDC(), GetStockObject(GRAY_BRUSH));
	TextOut(m_pBackBuffer->getDC(), 50, 50, _buffer, wcslen(_buffer));
}